package _interview150;

/**
 * 11. 盛最多水的容器
 */
public class No11 {
    public int maxArea(int[] height) {
        int n = height.length;
        int left = 0, right = n - 1;

        int ans = 0;
        while (left < right) {
            ans = Math.max((right - left) * Math.min(height[left], height[right]), ans);
            if (height[left] < height[right]) left++;
            else right--;
        }
        return ans;
    }
}
